package szkeleton;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class PlayerView implements Paintable
{
	private int index;
	private Player player;
	private int playersize;
	
	public PlayerView(Player p, int i)
	{
		player=p;
		index=i;
	}
	
	public void setPlayerSize(int i)
	{
		playersize=i;
	}

	@Override
	public void Paint(Graphics2D g, Point start, Point end) 
	{
		if (index==0)
			{
			BufferedImage img = null;
			try
			{
				img = ImageIO.read(new File("./img_res/player1.png"));
			}
			catch (Exception e)
			{
				Gamelogic.getController().getView().showError(e.getMessage());
				//e.printStackTrace();
			}
			g.drawImage(img, start.x+player.getPosition().x*playersize, start.y+player.getPosition().y*playersize, playersize, playersize, Color.white, null);
			}
		else 
		{
			BufferedImage img = null;
			try
			{
				img = ImageIO.read(new File("./img_res/player2.png"));
			}
			catch (Exception e)
			{
				Gamelogic.getController().getView().showError(e.getMessage());
				//e.printStackTrace();
			}
			g.drawImage(img, start.x+player.getPosition().x*playersize, start.y+player.getPosition().y*playersize, playersize, playersize, Color.white, null);
		
		}
		
	}
	

}
